package com.github.chirspan.xaas.uc.web.api;


import com.github.chirspan.xaas.api.BaseCRUDRestController;
import com.github.chirspan.xaas.bo.OrgAndDeptBo;
import com.github.chirspan.xaas.core.rest.RestResult;
import com.github.chirspan.xaas.uc.model.OrgOrganization;
import com.github.chirspan.xaas.uc.service.IOrgOrganizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * @Author: chenpan
 * @Date: 2021-08-10 11:03:10
 * @Description: 机构信息 REST API
 */
@RestController
@RequestMapping("organization")
public class OrgOrganizationController extends BaseCRUDRestController<OrgOrganization> {

    @Autowired
    private IOrgOrganizationService organizationService;

    @GetMapping("/department/_tree")
    public RestResult getOrgAndDeptTree(OrgAndDeptBo bo, boolean isAbleOrg) {
        List<OrgAndDeptBo> list = organizationService.getOrgAndDeptTree(bo, isAbleOrg);
        return RestResult.OK(list, "请求成功");
    }

    @GetMapping("/_tree")
    public RestResult getOrgTree(OrgOrganization organization) {
        List<OrgOrganization> list = organizationService.getOrgTree(organization);
        return RestResult.OK(list, "请求成功");
    }
}
